package PTA.Mianxiangduixiang.ex15;

public class ex15{
    public static void main(String[] args) {
        Person[] p = new Person[3];
        for(int i=0;i<p.length;i++){
            p[i]=new Person();
        }
        p[0].setName("zhangsan");
        p[0].setAge(18);
        p[1].setName("lisi");
        p[1].setAge(20);
        p[2].setName("wangwu");
        p[2].setAge(22);
        for (int i = 0; i < p.length; i++) {
            System.out.println(p[i]);
        }
    }
}
class Person {
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
super();
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return name+" "+age;
    }
}